package cn.hdu.liang.enumerated;


import java.util.EnumSet;

public class CarWash {
    public enum Cycle {
        UNDERBODY {
            void action() {
                System.out.println("底盘喷漆");
            }
        },
        WHEELWASH {
            void action() {
                System.out.println("洗车轮");
            }
        },
        PREWASH {
            void action() {
                System.out.println("擦车");
            }
        },
        BASIC {
            void action() {
                System.out.println("基本清理");
            }
        },
        HOTWAX {
            void action() {
                System.out.println("打蜡");
            }
        },
        RINSE {
            void action() {
                System.out.println("冲车");
            }
        },
        BLOWDRY {
            void action() {
                System.out.println("吹干");
            }
        };

        abstract void action();
    }

    EnumSet<Cycle> cycles = EnumSet.of(Cycle.BASIC, Cycle.RINSE);

    public void add(Cycle cycle) {
        cycles.add(cycle);
    }

    public void washCar() {
        for(Cycle c : cycles) {
            c.action();
        }
    }

    public String toString() {
        return cycles.toString();
    }

    public static void main(String[] args) {
        CarWash wash = new CarWash();
        System.out.println(wash);
        wash.washCar();

        wash.add(Cycle.BLOWDRY);
        wash.add(Cycle.BLOWDRY);
        wash.add(Cycle.RINSE);
        wash.add(Cycle.HOTWAX);
        System.out.println(wash);
        wash.washCar();
    }
}